
%testing the influence of starting value x1 on the convergence order

a=1;
t0=0;
T=1.0;
f=@(x,t) a*x;
ft=@(x,t) 0;
fx=@(x,t) a;

sol=@(t) exp(a*(t-t0));
x0=1.0; 

N=20;
M=8;
er=zeros(M,3);
for k=1:M,
 h=(T-t0)/N;
 %x1 - solution at t1
 x1=sol(h);
 [X1,t]=AdamsBashforth19(f,t0,T,x0,x1,N);
 er(k,1)=norm(sol(t)-X1,'inf');
 %one step of forward Euler
 f0=f(x0,t0); x1=x0+h*f0; 
 er1(k,1)=x1-sol(h);
 [X2,t]=AdamsBashforth19(f,t0,T,x0,x1,N);
 er(k,2)=norm(sol(t)-X2,'inf');
 %one step of Heun method
 x1=x0+0.5*h*(f0+f(x0+h*f0,t0+h));
 er1(k,2)=x1-sol(h);
 [X3,t]=AdamsBashforth19(f,t0,T,x0,x1,N);
 er(k,3)=norm(sol(t)-X3,'inf');
 N*=2;
end 
er
er(1:M-1,:)./er(2:M,:)
er1(1:M-1,:)./er1(2:M,:)
